<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1,shrink-to-fit=no"
    />
    <title>OOM</title>
    <style>
      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      html,
      body {
        height: 100%;
      }

      #container {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>

  <body>
    <div id="container"></div>
    <!-- <script
      src="./assets/g/dist/index.umd.min.js"
      type="application/javascript"
    ></script>
    <script
      src="./assets/g-canvas/dist/index.umd.min.js"
      type="application/javascript"
    ></script> -->
    <script
      src="../packages/g/dist/index.umd.min.js"
      type="application/javascript"
    ></script>
    <script
      src="../packages/g-canvas/dist/index.umd.min.js"
      type="application/javascript"
    ></script>
    <script>
      const { Circle, Canvas, runtime } = window.G;

      const timeStart = performance.now();

      // create a renderer
      const canvasRenderer = new window.G.Canvas2D.Renderer();

      // create a canvas
      const canvas = new Canvas({
        container: 'container',
        width: 600,
        height: 500,
        renderer: canvasRenderer,
      });

      canvas.addEventListener('rerender', () => {
        console.log('time:', performance.now() - timeStart);
      });

      // canvas.addEventListener('ready', () => {
      for (let i = 0; i < 30000; i++) {
        const circle = new Circle({
          style: {
            cx: Math.random() * 600,
            cy: Math.random() * 500,
            r: 10,
            fill: '#1890FF',
            stroke: '#F04864',
            lineWidth: 4,
          },
        });
        canvas.appendChild(circle);
      }
      // });
    </script>
  </body>
</html>
